# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# 设置cmake的最低版本
cmake_minimum_required(VERSION 3.18.1)

#库的创建和命名，将其设置为STATIC或者SHARED
#并提供其源代码的相对路径
#您可以定义多个库，CMake为您构建他们
#用APK自动打包共享库
project("ndkdemo")

#2.编译library
add_library(
        # 设置库的名称
        ndkdemo

        #设置library模式
        #SHARED 模式会编译so文件，STATIC模式不会编译
        SHARED

        #设置原生代码路径
        native-lib.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
#搜索指定的预构建库并将路径存储为变量，因为CMake默认包含搜索路径中的系统库，您只需指定要添加的公共NDK库的名称即可。
#CMake在完成构建之前验证该库是否存在
find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        ndkdemo

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})